/**
 @file ctc_pon.h

 @author  Copyright (C) 2011 Centec Networks Inc.  All rights reserved.

 @date 2020-12-18

 @version v1.0

   This file contains all pon related data structure, enum, macro and proto.
*/

#ifndef _CTC_PON_H
#define _CTC_PON_H
#ifdef __cplusplus
extern "C" {
#endif
/****************************************************************
 *
 * Header Files
 *
 ***************************************************************/
#include "ctc_const.h"
#include "ctc_field.h"
#include "ctc_scl.h"
/****************************************************************
*
* Defines and Macros
*
****************************************************************/


enum ctc_pon_vlan_port_flag_e
{
    CTC_PON_VLAN_PORT_FLAG_FROM_UNI            = 0x00000001,    /**< [TM.TMM] uni service  */
    CTC_PON_VLAN_PORT_FLAG_FROM_NNI            = 0x00000002,    /**< [TM.TMM] nni service  */
    CTC_PON_VLAN_PORT_FLAG_PON_SERVICE         = 0x00000004,    /**< [TM.TMM] pon service , support for uni */
    CTC_PON_VLAN_PORT_FLAG_IGS_POLICER         = 0x00000008,    /**< [TM.TMM] ingress Policer ,  support when update uni */
    CTC_PON_VLAN_PORT_FLAG_DEFAULT_SERVICE  = 0x00000010,    /**< [TM.TMM] default service */
    CTC_PON_VLAN_PORT_FLAG_FID                         = 0x00000020,    /**< [TM.TMM] Forwarding id , support when update uni*/
    CTC_PON_VLAN_PORT_FLAG_PASS_THROUGH      = 0x00000040,    /**< [TM.TMM] pass through service */
    CTC_PON_VLAN_PORT_FLAG_KNOWN_MCAST_SERVICE  = 0x00000080,    /**<  [TM.TMM] known mcast service*/
    CTC_PON_VLAN_PORT_FLAG_VN_TAG                  = 0x00000100,    /**<  [TM.TMM] uplink packet will insert vn tag*/
    CTC_PON_VLAN_PORT_FLAG_SCL_ID                  = 0x00000200,    /**<  [TM.TMM] uplink service use scl_id valid */
};
typedef enum ctc_pon_vlan_port_flag_e ctc_pon_vlan_port_flag_t;

enum ctc_pon_vlan_port_match_s {
    CTC_PON_VLAN_PORT_MATCH_SVLAN_CVLAN,  /**< [TM.TMM] Match svlan + cvlan*/
    CTC_PON_VLAN_PORT_MATCH_SVLAN,            /**< [TM.TMM] Match svlan*/
    CTC_PON_VLAN_PORT_MATCH_FLEX_MAC,     /**< [TM] Match flexible*/
    CTC_PON_VLAN_PORT_MATCH_FLEX_IPV4,    /**< [TM.TMM] Match flexible*/
    CTC_PON_VLAN_PORT_MATCH_FLEX_IPV6,    /**< [TM] Match flexible*/
    CTC_PON_VLAN_PORT_MATCH_MAX
};
typedef enum ctc_pon_vlan_port_match_s ctc_pon_vlan_port_match_t;

enum ctc_pon_gem_port_flag_e
{
    CTC_PON_GEM_PORT_FLAG_PASS_THROUGH_EN     = 0x00000001,    /**< [TM.TMM] Pass through enable */
    CTC_PON_GEM_PORT_FLAG_MAC_LIMIT                   = 0x00000002,   /**< [TM.TMM] Mac limit action */
    CTC_PON_GEM_PORT_FLAG_FLOODING                    = 0x00000004,    /**< [TM.TMM] if set,indicate the gem port is flooding port */
};
typedef enum ctc_pon_gem_port_flag_e ctc_pon_gem_port_flag_t;

struct ctc_pon_gem_port_s
{
    /* key */
    uint32 gport;               /**< [TM.TMM]  [TM.TMM] [in]  Incomming network port*/
    uint32 tunnel_value;        /**< [TM.TMM]  [TM.TMM] [in]  GEM port vlan*/
    uint32 flag;                /**< [TM.TMM]  [in]  Flags, refer to ctc_pon_gem_port_flag_t*/
    
    /* gem_port */
    uint32 logic_port;          /**< [TM.TMM] [in] Logic port*/

    /* action */
    uint8  pass_through_en;      /**< [TM.TMM] [in] Pass through enable for current Gem */
    uint8  limit_action;        /**< [TM.TMM] [in] FDB mac limit, refer to ctc_maclimit_action_t*/
    uint16 igs_policer_id;      /**< [TM.TMM] [in] Ingress policer id */
    uint16 egs_service_id;      /**< [TM] [in] Egress service id */

};
typedef struct ctc_pon_gem_port_s ctc_pon_gem_port_t;


struct ctc_pon_vlan_port_s
{
    uint32 vlan_port_id;         /**< [TM.TMM]  [in] Entry identification */

    /* key */
    uint32 flag;                           /**< [TM.TMM]   [in]  Flags, refer to ctc_pon_vlan_port_flag_t*/
    ctc_pon_vlan_port_match_t criteria;    /**< [TM.TMM]   [in]  Match type*/
    uint32 gport;                          /**< [TM.TMM]   [in]  Incomming network port*/
    uint32 tunnel_value;                   /**< [TM.TMM]   [in]  GEM port vlan*/
    ctc_field_key_t* match_fields;         /**< [TM.TMM]   [in]  Match key field array*/
    uint16 fields_num;                     /**< [TM.TMM]   [in]  Match key field numbers*/
    uint8  scl_id;                         /**< [TM.TMM]   [in] SCL lookup ID. There are 2 scl hash lookup<0-1>, and 2 tcam lookup<2-3> */
    uint32 scl_eid;                        /**< [TM.TMM]   [out] return scl entry id */
    
    /* action */
    uint16 fid;               /**< [TM.TMM] [in] Forwarding id*/
    uint16 volt_tag;             /**< [TM.TMM] [in] volt-tag*/
    uint8 volt_tag_valid;             /**< [TM.TMM] [in] if set, uplink packet will insert volt_tag*/
    uint16 vn_tag;              /**< [TM.TMM] [in] if set , uplink packet will insert vn_tag: bit 0 ~ bit 6 indicate gem port id, bit 7 ~ bit 11 indicate uni port id*/
    uint16 igs_policer_id;    /**< [TM.TMM] [in] Ingress policer id */
    uint32 xlate_nhid;        /**< [TM.TMM] [in] Vlan xlate nhid*/
    uint32 dsnh_offset;       /**< [TM.TMM] [in] Vlan xlate Nexthop offset*/
    uint32 logic_port;        /**< [TM.TMM] [in] Logic port for vlan port*/
    uint32 logic_dest_port;  /**< [TM.TMM] [in] Logic dest port */
    ctc_scl_vlan_edit_t igs_vlan_action;  /**< [TM.TMM] [in] Ingress vlan action */
    ctc_scl_vlan_edit_t egs_vlan_action;  /**< [TM.TMM] [in] Egress vlan action */


};
typedef struct ctc_pon_vlan_port_s ctc_pon_vlan_port_t;

enum ctc_pon_port_cfg_type_e
{
    CTC_PON_PORT_CFG_UNI_EN,   /**< [TM.TMM] UNI port enable*/
    CTC_PON_PORT_CFG_NNI_EN,   /**< [TM.TMM] NNI port enable*/
    CTC_PON_PORT_CFG_NNI_LOGIC_PORT,  /**< [TM.TMM] NNI port logic port*/
};
typedef enum ctc_pon_port_cfg_type_e ctc_pon_port_cfg_type_t;

enum ctc_pon_port_flag_e
{
    CTC_PON_PORT_FLAG_DIS_UNKNOWN_MCAST_LOOKUP  = 0x00000001,    /**<  unknown mcast not forward  known service*/
};
typedef enum ctc_pon_port_flag_e ctc_pon_port_flag_t;

struct ctc_pon_port_cfg_s
{
    uint8 type;  /**< [TM.TMM] Config type,  refer to ctc_pon_port_cfg_type_t */
    ctc_pon_vlan_port_match_t criteria;  /**< [TM.TMM]  Vlan port match type, when set uni or nni enable*/
    uint32 flag;                           /**<   [TM.TMM] Flags, refer to ctc_pon_port_flag_t*/
    uint32 value; /**< [TM.TMM] Value */
};
typedef struct ctc_pon_port_cfg_s ctc_pon_port_cfg_t;

struct ctc_pon_global_cfg_s
{
    uint8 mode;         /**< [TM.TMM] if mode = 1, means ipv4/ipv6/pppoe packet use different pon service; mode = 2 means hybrid mode*/
    uint8 rsv;
    uint32 gem_port_num; /**< [TM.TMM] max gem port num, valid only in mode 2, default value is 16k*/
};
typedef struct ctc_pon_global_cfg_s ctc_pon_global_cfg_t;

#ifdef __cplusplus
}
#endif

#endif  /*_CTC_PON_H*/
